using Map;

namespace Entity.Monster
{
    public class MonsterViewController : ActorViewController
    {
        public Monster Monster => (Monster)Actor;
        
        //检测是否转换地图块
        public void CheckAndTransferMapBlock()
        {
            //通过AI所在的坐标的地图块 和 AI归属的地图块做比较
            var newBlock = MapManager.Instance.GetMapBlockByWorldPosition(transform.position);
            if (newBlock == Monster.MonsterObject.MapBlock) return;
            //从当前地图块移除
            Monster.MonsterObject.MapBlock.RemoveAIObjectOnTransfer(Monster.MonsterObject.AIData.ID);
            //加入新的地图块
            newBlock.AddAIObjectOnTransfer(Monster.MonsterObject.AIData, Monster.MonsterObject);
        }
    }
}